package com.sgb.member.ui.adapter;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.View;

import com.sgb.member.BR;
import com.sgb.member.R;
import com.sgb.member.databinding.ItemBiddingQuotationBinding;
import com.sgb.member.entity.BiddingRegisterBean;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;
import com.swgk.core.util.PointUtils;

import java.util.List;

public class BiddingQuotationAdapter extends BaseRecycleAdapter<BiddingRegisterBean> {

    public BiddingQuotationAdapter(Context context, List<BiddingRegisterBean> datas) {
        super(context, R.layout.item_bidding_quotation, datas);
    }

    @SuppressLint("UseCompatLoadingForDrawables")
    @Override
    public void convert(ItemViewHolder holder, BiddingRegisterBean bean) {
        holder.setBinding(BR.viewModel, bean);
        ItemBiddingQuotationBinding binding = (ItemBiddingQuotationBinding) holder.getmBinding();
        String price = PointUtils.price(bean.getMoney());
        if (price.endsWith(".00")) {
            price = price.split("\\.")[0];
        }
        binding.tvBiddingPrice.setText(String.format("%s元", price));

        binding.ivBiddingStatus.setVisibility(View.VISIBLE);
        switch (bean.getState()) {
            case 2:
                binding.ivBiddingStatus.setBackground(context.getResources().getDrawable(R.mipmap.member_icon_jjz));
                break;
            case 3:
                binding.ivBiddingStatus.setBackground(context.getResources().getDrawable(R.mipmap.member_icon_yjs));
                break;
            case 5:
                binding.ivBiddingStatus.setBackground(context.getResources().getDrawable(R.mipmap.member_icon_fb));
                break;
            case 7:
                binding.ivBiddingStatus.setBackground(context.getResources().getDrawable(R.mipmap.member_icon_liubiao));
                break;
            default:
                binding.ivBiddingStatus.setVisibility(View.GONE);
                break;
        }
        if (bean.getState() > 0) {
            binding.ivBiddingStatus.setVisibility(View.VISIBLE);
        } else {
            binding.ivBiddingStatus.setVisibility(View.GONE);
        }
    }
}
